package com.lucenex.core.plugins;



import java.io.IOException;

import org.apache.log4j.Logger;

import com.jfinal.plugin.IPlugin;
import com.lucenex.core.LuceneX;

/**
 * jfinal 插件
 * @author zxw
 *
 */
public class JfinalLuceneX implements IPlugin{
	
	private Logger log = Logger.getLogger(JfinalLuceneX.class);
	
	Class<?> coreConfig;
	
	@SuppressWarnings("unused")
	private JfinalLuceneX() {
	}
	
	public JfinalLuceneX(Class<?> coreConfig) {
		this.coreConfig = coreConfig;
	}

	@Override
	public boolean start() {
		if(this.coreConfig != null) {
			try {
				LuceneX.start(this.coreConfig);
				return true;
			} catch (InstantiationException | IllegalAccessException | IOException e) {
				log.error("启动LuceneX ERROR", e);
				return false;
			}
		}else {
			return false;
		}
	}

	@Override
	public boolean stop() {
		//有自动回收站  无需管理
		return false;
	}

}
